Welcome to 'Serverless Pros and Cons.' After watching this video, you will be able to describe the benefits of serverless computing, describe the constraints of serverless computing, and compare serverless pros and cons with
containers and traditional computing. So let's first understand the challenges
with traditional computing and how the advent of serverless
computing overcomes these. In traditional computing, development and operations teams set up
and maintain their own infrastructure. These processes take a lot of time, are
complex, and require capital investments. However, with the arrival of cloud,
containers, and serverless computing, development teams can focus
on writing high-quality code and building and running their
applications in milliseconds without worrying about infrastructure,
scalability, and fault tolerance. But serverless computing also has its share
of challenges, including vendor lock-in, third-party dependencies, and networking. Let's look at the benefits and constraints
of serverless computing and then compare the same versus containers
and traditional computing. With serverless computing, cloud providers take on a large share
of the work, which brings many benefits. There are no infrastructure setup and
maintenance requirements as a cloud provider manages the same, thereby reducing costs. Cloud providers ensure reliability, which
results in high availability and fault tolerance. Developers benefit because they focus on
applications and do what they enjoy best. Without serverless, all parts of your applications
are constantly running, thereby wasting resources. Serverless functions allow you to configure your
application to only run certain parts when needed. For example, an application’s front end must
run continuously to keep users logged in. But an authentication service saves resources
and costs since it is only invoked occasionally. Functions run in milliseconds,
while run times for containers or virtual machines (VMs) are in
seconds and minutes, respectively. Many cloud providers include a
built-in code editor called an Integrated Development Environment, or IDE, for
faster developments, deployments, and updates. You are charged on a pay-per-request
basis and not for any idle resources. You can use any popular programming
language for development. Plenty of third-party support
is available for authentication, database, and other backend services. Since developers purely focus on development, organizations can focus on their business and
release products faster than the competition. The serverless environment allows more innovation
and experimentation, even if subject to failures. And with no infrastructure to manage, greener
computing also becomes a definite possibility. However, serverless computing is not best for
every situation as it does have some constraints: Many organizations realize significant cost
savings for spiky workloads, but for workloads characterized by long-running processes, the
benefits diminish from the pay-per-use model. And for such applications, a traditional
environment can be more cost-effective. Dependencies on cloud providers’ technologies
and environments lead to vendor lock-in risks. If requests are received after long intervals, the applications must often restart
all processes, known as a cold start. And this increases the function run time. Serverless latency is unacceptable for
time-critical applications such as banking, health care, or edge-related applications. Security concerns increase due to changes
in the attack surfaces from endpoints to source code and the limitations in the
provider’s security implementations. Monitoring and debugging are
complex in any distributed system. Since you cannot imitate the backend-as-a-service
(or BaaS) environment in your local system, it’s challenging to test the complete
functionality and debug application issues. Language support is dependent
on the cloud provider. And not all cloud providers offer support
for all programming languages; hence you are limited to the languages
supported by your cloud provider. There are no servers to optimize for utilization or performance since you have
no control over the servers. And there is no state persistence. For example, the previous run
state will not be available in the next invocation of the same function. Since local cache lasts only a few hours, it’s better to include low-latency
external caches like Redis or Memcached. Can serverless and containers work together? Absolutely! Serverless and containers
are not mutually exclusive. They work best together in a hybrid solution. If you’re struggling to choose
between serverless or containers, follow the standard industry advice: “Build serverless first, and if
needed, move to containers”. Let’s compare serverless computing
and containerization, starting with the pros of serverless and the cons of containers: Serverless computing is more cost-effective
since you only pay for what you use. For serverless, scalability is handled
entirely by the cloud provider. The cloud provider manages all the infrastructure. The time to deploy is a matter of
milliseconds rather than seconds. And in terms of speed to market, as
development is fast, organizations can focus on their core business and
not worry about the infrastructure. Now, let’s consider the pros of
containers and the cons of serverless: With containers, testing in a local
environment or in the cloud is easier. It’s easier to port containers as
they are operating system agnostic, language agnostic, and provider agnostic. Latency is very low for containers, so it’s
suitable even for time-critical workloads. Containers are also ideal for
long-running apps as there are no time restrictions to complete batch jobs. With containers, you can
configure both apps and resources. And for language support,
containerization supports any language. And now, let’s compare serverless
computing and traditional computing, starting with the pros of serverless
and the cons of traditional computing: Serverless architecture is a cloud computing model in which developers focus on
writing high-quality code. Serverless computing is more cost-effective
since you only pay for what you use. Scalability is handled
entirely by the cloud provider. And libraries and integrations are
available within the application. And finally, let’s consider the pros of
traditional computing and the cons of serverless:​ With traditional computing,
data is under your control.​ In terms of networking, your access
code via regular Internet Protocol (or IP) addresses rather than setting up private
application programming interfaces (or APIs).​ Security only needs to be implemented within
the organization’s network perimeter.​ And since you manage the entire
setup, vendor lock-in is quite rare. In this video, you learned that: With traditional computing, you set
up and maintain the infrastructure, with serverless computing, development teams
can focus on writing high-quality code, serverless computing offers several benefits
including built-in high availability and fault tolerance, faster function run
times, and pay-per-request billing, serverless computing also has constraints,
including unacceptable latency for time-critical apps, complex monitoring
and debugging, and no state persistence, serverless and containers
are not mutually exclusive, and they work best together in a hybrid solution, and finally, serverless and traditional
computing each have pros and cons.